/**
 * UploadMoreAction.java
 * jp.co.greenblue.ecodasweb.web.struts2.action
 *
 * Function： TODO 
 *
 *   ver     date      		author
 * ──────────────────────────────────
 *   		 2010/11/12 		jonsion
 *
 * Copyright (c) 2010, GreenBlue .  All Rights Reserved.
 */

package jp.co.greenblue.ecodasweb.web.struts2.action;

import java.io.File;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

/**
 * ClassName:UploadMoreAction Function: TODO ADD FUNCTION Reason: TODO ADD
 * REASON
 * 
 * @author jonsion
 * @version
 * @since Ver 1.1
 * @Date 2010/11/12 15:00:16
 * 
 * @see
 */
public class UploadMoreAction extends ActionSupport {
	/**
	 * serialVersionUID:TODO（用一句话描述这个变量表示什么）
	 *
	 * @since Ver 1.1
	 */
	
	private static final long serialVersionUID = -2275430744688294793L;
	private java.util.List<File> uploads;
	private java.util.List<String> fileNames;
	private java.util.List<String> uploadContentTypes;

	public java.util.List<String> getUploadFileName() {
		return fileNames;
	}

	public void setUploadFileName(java.util.List<String> fileNames) {
		this.fileNames = fileNames;
	}

	public java.util.List<File> getUpload() {
		return uploads;
	}

	public void setUpload(java.util.List<File> uploads) {
		this.uploads = uploads;
	}

	public void setUploadContentType(java.util.List<String> contentTypes) {
		this.uploadContentTypes = contentTypes;
	}

	public java.util.List<String> getUploadContentType() {
		return this.uploadContentTypes;
	}

	public String execute() throws Exception {
		if (uploads != null) {
			int i = 0;
			for (; i < uploads.size(); i++) {
				java.io.InputStream is = new java.io.FileInputStream(
						uploads.get(i));
				java.io.OutputStream os = new java.io.FileOutputStream(
						"d:\\upload\\" + fileNames.get(i));
				byte buffer[] = new byte[8192];
				int count = 0;
				while ((count = is.read(buffer)) > 0) {
					os.write(buffer, 0, count);
				}
				os.close();
				is.close();
			}
		}
		return SUCCESS;
	}
}
